<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/decorators/taglibs.jsp"%>
<div class="w1a">    
<div><h2>第${sessionNo}期會期目次表</h2></div>
<div>
	<img src="${appPath}/themes/icons/List.png" height="20" width="20"/>目次表：
	<c:choose>
		<c:when test="${ not empty fileMap['schedule']}">
			<a href="javascript:download('${fileMap['schedule'][0]}');" style="margin-right:50px;">下載</a>
		</c:when>
		<c:otherwise>
			<font color="red" style="margin-right:50px;">[尚無檔案]</font>
		</c:otherwise>
	</c:choose>
	<img src="${appPath}/themes/icons/Notes.png" height="20" width="20"/>會議記錄：
	<c:choose>
	<c:when test="${ not empty fileMap['r01']}">
		<a href="javascript:download('${fileMap['r01'][0]}');" style="margin-right:50px;">下載</a>
	</c:when>
	<c:otherwise>
		<font color="red" style="margin-right:50px;">[尚無檔案]</font>
	</c:otherwise>
	</c:choose>
	
	<c:choose>
		<c:when test="${type eq 'pdf'}"> 
			檔案類型：<img src="${appPath}/themes/icons/pdf_2.png"
				style="vertical-align: text-bottom; height: 60px; width: 60px;" />
		</c:when>
		<c:when test="${type eq 'tif'}"> 
			檔案類型：<img src="${appPath}/themes/icons/tif.png"
				style="vertical-align: text-bottom; height: 60px; width: 60px;" />
		</c:when>
		<c:otherwise>
		</c:otherwise>
	</c:choose>
</div>
<form:form modelAttribute="fileForm" id="fileForm" method="post" class="form">
	<form:hidden path="sessionNo" id="sessionNo"/>
	<form:hidden path="filename" id="filename"/>
</form:form>
<table id="dg" class="easyui-datagrid" url="${appPath}/motionView/list.json" align="center" 
	data-options="onBeforeLoad:function(param){$.each($('#fileForm').serializeArray(), function(i, v) { param[v.name] = v.value;});}"
	singleSelect="true" striped="true" title="目次表" rownumbers="true" nowrap="false" autoRowHeight="true" fitColumns="false">
	<thead>      
    	<tr>   
            <th field="typeNo" width="120px" formatter="typeFormat">案別</th>  
            <th field="cause" width="700px">案由</th>  
            <th field="action" width="200px" formatter="action">作業</th>  
		</tr>   
	</thead>   
</table> 
</div>
<script type="text/javascript">
$.ajaxSetup ({
    cache: false,
    async:false
});
$(function() {
});
function typeFormat(val,row,ix){
	var o = $('#dg').datagrid('getData').rows[ix];
	var preffix = o.provisional;
	var str = "";
	switch(val){
	case '0':
		str = "報告案"+o.motionOrder;
		break;
	case '1':
		str = "討論案"+o.motionOrder;
		break;
	case '2':
		str = "評議案"+o.motionOrder;
		break;
	case '3':
		str = "審議案"+o.motionOrder;
		break;
	case '9':
		str = "動議案"+o.motionOrder;
		break;
	}
	if(preffix){str = "臨時"+str;}
	return str;
}

function action(val,row,ix){ var str = "";
	var o = $('#dg').datagrid('getData').rows[ix];
	$.ajax({url:"${appPath}/motionView/fileExists/"+o.session.sessionNo+"/"+o.motionNo+".json", 
		async:false ,cache:false, success:function(d){ 
			if(eval(d)){
				str = str.concat("[<a target='_blank' href='${appPath}/motionView/motionDetail/"+o.motionNo+".htm'>議案影像檔案</a>]");
			}else{
				str = str.concat("<font color='red'>[尚無檔案]</font>");
			}
		}
	});	
	return str; 
} 
function doSearch(){ var object = {};
	$.each($('#searchForm').serializeArray(), function(i, v) { object[v.name] = v.value; });
	$('#dg').datagrid('load', object ); 
} 
function download(fileName){
	$("#filename").val(fileName);
	$( "#fileForm" ).attr("action","${appPath}/files/exp.htm").submit();
}

</script>